package com.yunduo.world.utils;

import com.yunduo.world.constant.NetWorkConstant;
import io.netty.util.CharsetUtil;
import org.springframework.util.StringUtils;

/**
 * String 工具类
 */
public class YStringUtils extends StringUtils {

    // 设置编码为utf8并去除末尾分隔符
    public static byte[] UTF8String(String data) {
        data = data.substring(0,data.length()- NetWorkConstant.split.length());
        return data.getBytes(CharsetUtil.UTF_8);
    }

    // 切割业务请求，将业务所属具体操作拆分
    public static String[] splitByBusiness(String str) {
        if (isEmpty(str)){
            return null;
        }
        String[] split = str.split(NetWorkConstant.split);
        return split;
    }

    // 字符串判空
    public static boolean isEmpty(String str) {
        if (null == str || "".equals(str)){
            return true;
        }
        return false;
    }
}
